#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

long long atolong(const char * str)
{
	if (str == NULL) return 0;
	
	long long num = 0;

	int len =  strlen(str);

	for (int i = 0; i < len; ++i,str++)
	{
		char n[2];
		sprintf(n, "%c", *str);
		int k = atoi(n);
		num = num * 10 + k;
	}

	return num;
}

int main(int argc, char const *argv[])
{

	FILE* f = fopen("tw-02.txt", "r");

	FILE* ff = fopen ("tw-02-newone.txt", "w+");

	char buf[100];
	while( fgets(buf, 100, f) != NULL)
	{
		// printf("%s %d\n", buf, strlen(buf));

		if (strlen(buf) == 1 && (buf[0] == '\n' || buf[0] == ' '))
		{
			// printf("%s", buf);
			continue;
		}

		char time[100];
		sscanf (buf, "%s", time);
		time_t tLogoutTime = atolong(time);
		tm tp;
		localtime_r(&tLogoutTime, &tp);
	
		char	szTime[128] = { 0 };
		sprintf(szTime, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d", tp.tm_year + 1900, tp.tm_mon + 1, tp.tm_mday, tp.tm_hour, tp.tm_min, tp.tm_sec);
		// printf("%s\n", szTime);

		char *match = strstr(buf, "\t");
		char sGuid[102];
		sscanf(match, "%s", sGuid);
		long long nGuid = atolong(sGuid);
		// printf("%llX\n", nGuid);

		char line[100];
		sprintf(line, "%s\t%llX", szTime, nGuid);
		// printf("%s\n", line);
		fwrite(line, 1, strlen(line), ff);
		// printf("%d\n", strlen(line));
		fwrite("\n", 1, 1, ff);
	}


	return 0;
}